home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16951 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  61 lines

  1. Newsgroups: comp.lang.c++
  2. Path: dmocc2.on.bell.ca!bc2cep!news
  3. From: Eric Marc Loebenberg <loebenbe@qc.bell.ca>
  4. Subject: Can you help? Switching menus stored in DLL Resource
  5. X-Nntp-Posting-Host: cmocft.qc.bell.ca
  6. Content-Type: text/plain; charset=us-ascii
  7. Message-ID: <316EC457.1AAE@qc.bell.ca>
  8. Sender: news@on.bell.ca (news admin)
  9. Content-Transfer-Encoding: 7bit
  10. Organization: Bell Sygma
  11. Mime-Version: 1.0
  12. Date: Fri, 12 Apr 1996 21:00:07 GMT
  13. X-Mailer: Mozilla 2.0 (Win95; I)
  14.  
  15. Hi perhaps someone can give me a hand.    
  16. I am using Visual C++ versions 4.0 and 1.52 (separately)    
  17.  
  18. I am building an application that will run in 1 of several languages.
  19. All linguistic resources are stored in a DLL for that language.
  20.  
  21. I thought it would be need to be able to switch the language on the fly
  22. while running the application.  For example, to to the Options menu
  23. Language submenu and pick a language.    
  24.  
  25. I would then drop one DLL load the other, kill the menu and load the 
  26. new menu.
  27.  
  28. THIS ALMOST WORKS with one problem.
  29. All strings and dialogs appear in the new language and so does the 
  30. menu.  HOWEVER, when I choose a submenu, I get
  31.  
  32. In Version 1.52 Debug
  33. Assertion Failed: file Winmenu.cpp  Line 42
  34.  
  35. This line is flagged with a * below
  36.  
  37. CMenu* PASCAL CMenu::FromHandle(HMENU hMenu)
  38. {
  39.   CMenu* pMenu = (CMenu*)_afxMapHMENU.FromHandle(hMenu);
  40. * ASSERT(pMenu == NULL || pMenu->m_hMenu == hMenu);
  41.   return pMenu;
  42. }
  43.  
  44. The code that I am using to switch languages is
  45.  
  46. void CMptFrame::SetLanguage(char cLang)
  47. {
  48.   CMenu *ThisMenu = GetMenu();
  49.   ThisMenu->DestroyMenu();
  50.   ThisDoc->Lang = cLang;
  51.   ThisApp.DLL[ThisApp.DLLLangIndex] = cLang;
  52.   FreeLibrary(ThisApp.m_hInstDLL);
  53.   ThisApp.m_hInstDLL =::LoadLibrary(ThisApp.DLL);
  54.   AfxSetResourceHandle(ThisApp.m_hInstDLL); // get resources from DLL
  55.   ThisMenu->LoadMenu(IDR_MAINFRAME);
  56.   SetMenu(ThisMenu);
  57.   DrawMenuBar();
  58. }
  59.  
  60. Thanks.
  61.